package org.uu.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.uu.mybatisplus.dao.IpWhiteList;
import org.uu.mybatisplus.mapper.IpWhiteListMapper;
import org.uu.mybatisplus.service.TestEngineerService;

import javax.annotation.Resource;

@Service
public class TestEngineerServiceImpl extends ServiceImpl<IpWhiteListMapper, IpWhiteList> implements TestEngineerService {

    @Resource
    private IpWhiteListMapper whiteIpMapper;

    @Override
    public Boolean getIp(String name) {
        try {
            //查询表中是否有此IP，并且状态是打开的状态
            IpWhiteList whiteIp = whiteIpMapper.selectOne(new QueryWrapper<IpWhiteList>().eq("ip", name).eq("state", "1"));
            if(whiteIp==null){
                return false;
            }else{
                return true;
            }
        }catch (Exception e){
            return false;
        }
    }
}
